<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>用户组权限管理</title>
	<link rel="stylesheet" type="text/css" href="../css/index.css"></link>
	<script src="../js/common.js"></script>
	<script src="../js/jquery.plugins/jquery.js"></script>
	<link rel="stylesheet" type="text/css" href="../js/jquery.plugins/easyui/css/default/easyui.css"></link>
	<link rel="stylesheet" type="text/css" href="../js/jquery.plugins/easyui/css/icon.css"></link>
	<script src="../js/jquery.plugins/easyui/jquery.easyui.min.js"></script>
	<script src="../js/jquery.plugins/easyui/easyui-lang-zh_CN.js"></script>
	<script>
		$(function(){
			$('#saveBtn').linkbutton({iconCls:'icon-save',text:"保存",plain:true});
			$('#backBtn').linkbutton({iconCls:'icon-back',text:"返回上一页",plain:true});
			$('#tree').tree({checkbox:true,animate:true});
			var pIds = [${pIds}];
			checkTree( "tree" , pIds );
			$("form").submit(function(){
					var nodes = $('#tree').tree('getChecked');
					var param = "id=" + $('#id').val();
					$(nodes).each(function(i){ param += "&pIds=" + this.id;});
					$.ajax( {
						url:"savePermission.ht",
						data:param,
						method:'post',
						dataType:'json',
						success:function( flag ){
							if( flag ){
								$.messager.alert( '提示',"保存成功",'info');
							}else{
								$.messager.alert( '提示',"保存失败",'info');
							}
						}
					});
					return false;
				}	
			);
		});
	</script>
</head>
<body>
	<!-- 导航部分 -->
	<div class="position">
	您当前的位置：系统管理 &gt;&gt; <a href="list.ht">用户组管理</a> &gt;&gt; 权限设置
	</div>
	<!-- 导航部分结束 -->
	<!-- 表单部分开始 -->
	<div>
		<form action="savePermission.ht" method="post">
			<input type="hidden" name="id" id="id" value="${model.id}"/>
			<table class="form" style="width:50%;">
				<tr>
					<td class="title" style="width:100px;">组名称：</td>
					<td>${model.name }</td>
				</tr>
				<tr>
					<td class="title">简介：</td>
					<td>${model.memo }</td>
				</tr>
				<tr>
					<td class="title">权限设置：</td>
					<td>
						<c:set var="first" value="true"/>
						<c:set var="preLev" value="1"/>
						<ul id="tree">
							<c:forEach var="p" items="${ permissions }"><c:choose>
							<c:when test="${p.lev == preLev}"><c:if test="${first=='false'}"></li></c:if></c:when>
							<c:when test="${p.lev >preLev}"><ul></c:when><c:otherwise><c:forEach begin="1" end="${preLev-p.lev}" step="1"></li></ul></c:forEach></li></c:otherwise></c:choose>
							<li id="${p.id}"><span><label title="${p.memo}">${p.name}</label></span>
							<c:set var="first" value="false"/><c:set var="preLev" value="${p.lev}"/></c:forEach>
							<c:forEach begin="2" end="${preLev}" step="1"></li></ul></c:forEach>
							</li>
						</ul>
					</td>
				</tr>
				<tr>
					<td colspan="2" class="btntd">
					<a href="javascript:commit();" id="saveBtn">保存</a>
					<a href="javascript:goBack();" id="backBtn">返回上一页</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<!-- 表单部分结束  -->
</body>
</html>